package com.example.demo.controller.people;


import com.example.demo.model.ResponseMessage;
import com.example.demo.model.people.Customer;
import com.example.demo.model.people.Provider;
import com.example.demo.service.people.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService service;

    @RequestMapping("save")
    public ResponseMessage save(Customer customer){
        ResponseMessage responseMessage = new ResponseMessage();
        Boolean flag = service.save(customer);
        responseMessage.setFlag(flag);

        return  responseMessage;
    }

    @RequestMapping("selectAll")
    @ResponseBody
    public List<Customer> selectAll(){ return service.selectAll(); }
    @RequestMapping("addCustomer")
    public Integer addCustomer(Customer customer){return service.addCustomer(customer);}
    @RequestMapping("deleteById")
    public Boolean deleteById(Integer customer_id){return service.deleteById(customer_id)==1;}
    @RequestMapping("updateById")
    public Integer updateById(Customer customer){return service.updateById(customer);}
    @RequestMapping("findCustomer")
    @ResponseBody
    public List<Customer> findCustomer(String customer_name,String connectionpersion,String customer_phone){ return service.findcustomer(customer_name,connectionpersion,customer_phone);}


}
